how to count words in javascript